package classesInterface;

import classesBancodeDados.FichaClinicaMedica;
import classesBancodeDados.Paciente;
import classesJpa.FichaClinicaMedicaJpaController;
import classesJpa.exceptions.NonexistentEntityException;
import classesMiolo.DataHorario;
import classesMiolo.Formatador;
import classesMiolo.MapasClinicaMedica;
import classesMiolo.ReverseMapper;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;

public class TelaFichaCMExameFisicoEspecial extends javax.swing.JFrame {

    /**
     * Creates new form CMExameFisicoEspecial
     */
    private TelaFichaCMExameFisicoEspecial() {
        initComponents();
        setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    }
    
    public static TelaFichaCMExameFisicoEspecial getInstance(){
        if(instance == null) instance = new TelaFichaCMExameFisicoEspecial();
        return instance;
    }
    
    public void limpaCampo(){
        TelaFichaCMExameFisicoEspecial efe = TelaFichaCMExameFisicoEspecial.getInstance();
        efe.areaAlterClin.setText("");
        efe.areaConclusao.setText("");
        efe.campoNome.setText("");
        efe.campoOutros.setText("");
        efe.campoObservacoes.setText("");
        efe.campoNeurologico.setText("");
        efe.campoObsEspec.setText("");
        efe.campoAvalNeuro.setText("");
        efe.campoIdade.setText("");
        efe.campoEnferm.setText("");
        efe.campoSegCefalico.setText("");
        efe.campoTorax.setText("");
        efe.campoBaco.setText("");
        efe.campoFigado.setText("");
        efe.campoRHA.setText("");
        efe.campoEdemas.setText("");
    }
    
    public void turnEditable(boolean editable){
        TelaFichaCMExameFisicoEspecial efe = TelaFichaCMExameFisicoEspecial.getInstance();
        this.editable = editable;
        botaoSalvar.setEnabled(editable);
        //Ficha
        efe.areaAlterClin.setEditable(editable);
        efe.areaConclusao.setEditable(editable);
        efe.campoAvalNeuro.setEditable(editable);
        efe.campoBaco.setEditable(editable);
        efe.campoEdemas.setEditable(editable);
        efe.campoFigado.setEditable(editable);
        efe.campoNeurologico.setEditable(editable);
        efe.campoObsEspec.setEditable(editable);
        efe.campoObservacoes.setEditable(editable);
        efe.campoOutros.setEditable(editable);
        efe.campoRHA.setEditable(editable);
        efe.campoSegCefalico.setEditable(editable);
        efe.campoTorax.setEditable(editable);
        efe.campoUltMenstruacao.setEditable(editable);
        efe.comboAbdome.setEnabled(editable);
        efe.comboDoloroso.setEnabled(editable);
        
        //Paciente
        efe.campoNome.setEditable(false);
        efe.campoIdade.setEditable(false);
        efe.campoEnferm.setEditable(false);
    }
    
    public void preencherCampos(Paciente p, FichaClinicaMedica cm){
        this.areaAlterClin.setText(cm.getAltClinicas());
        this.areaConclusao.setText(cm.getConclusao());
        this.campoAvalNeuro.setText(cm.getAvalNeuro());
        this.campoBaco.setText(cm.getBaco());
        this.campoEdemas.setText(cm.getEdemas());
        this.campoEnferm.setText(cm.getEnfermaria());
        this.campoFigado.setText(cm.getFigado());
        this.campoIdade.setText("" + DataHorario.calculaIdade(p.getDataDeNascimento()));
        this.campoNeurologico.setText(cm.getConsciencia());
        this.campoNome.setText(p.getNome());
        this.campoObsEspec.setText(cm.getObsEspec());
        this.campoObservacoes.setText(cm.getObservacao());
        this.campoOutros.setText(cm.getOutros());
        this.campoRHA.setText(cm.getRha());
        this.campoSegCefalico.setText(cm.getSegCefalico());
        this.campoTorax.setText(cm.getTorax());
        this.campoUltMenstruacao.setText(cm.getDataMenstruacao());
        MapasClinicaMedica mcm = MapasClinicaMedica.getInstance();
        this.comboAbdome.setSelectedItem(ReverseMapper.getKeyFromValue(mcm.getAbdome(), cm.getAbdome()));
        this.comboDoloroso.setSelectedItem(cm.isDoloroso() ? "Sim" : "Não");
    }

    public FichaClinicaMedica getFicha() {
        return ficha;
    }

    public void setFicha(FichaClinicaMedica ficha) {
        this.ficha = ficha;
    }
    
    private void salvar(){
        ficha.setAltClinicas(this.areaAlterClin.getText());
        ficha.setConclusao(this.areaConclusao.getText());
        ficha.setAvalNeuro(this.campoAvalNeuro.getText());
        ficha.setBaco(this.campoBaco.getText());
        ficha.setEdemas(this.campoEdemas.getText());
        ficha.setFigado(this.campoFigado.getText());
        ficha.setConsciencia(this.campoNeurologico.getText());
        ficha.setObsEspec(this.campoObsEspec.getText());
        ficha.setObservacao(this.campoObservacoes.getText());
        ficha.setOutros(this.campoOutros.getText());
        ficha.setRha(this.campoRHA.getText());
        ficha.setSegCefalico(this.campoSegCefalico.getText());
        ficha.setTorax(this.campoTorax.getText());
        ficha.setDataMenstruacao(this.campoUltMenstruacao.getText());
        ficha.setAbdome(MapasClinicaMedica.getInstance().getAbdome().get((String) this.comboAbdome.getSelectedItem()));
        ficha.setDoloroso(this.comboDoloroso.getSelectedItem().equals("Sim") ? true : false);
        FichaClinicaMedicaJpaController cmc = new FichaClinicaMedicaJpaController();
        try {
            cmc.edit(ficha);
        } catch (NonexistentEntityException ex) {
            Logger.getLogger(TelaFichaCMExameFisicoEspecial.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(TelaFichaCMExameFisicoEspecial.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public boolean isEditable() {
        return editable;
    }

    public void setEditable(boolean editable) {
        this.editable = editable;
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel3 = new javax.swing.JLabel();
        campoIdade = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        campoNome = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jSeparator2 = new javax.swing.JSeparator();
        jLabel4 = new javax.swing.JLabel();
        campoEnferm = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        jSeparator3 = new javax.swing.JSeparator();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        campoSegCefalico = new javax.swing.JTextField();
        campoTorax = new javax.swing.JTextField();
        comboAbdome = new javax.swing.JComboBox();
        jLabel8 = new javax.swing.JLabel();
        comboDoloroso = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        campoBaco = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        campoFigado = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        campoRHA = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        campoEdemas = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        campoOutros = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        campoUltMenstruacao = new javax.swing.JFormattedTextField();
        jLabel15 = new javax.swing.JLabel();
        campoObservacoes = new javax.swing.JTextField();
        jLabel16 = new javax.swing.JLabel();
        campoNeurologico = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        campoObsEspec = new javax.swing.JTextField();
        jLabel19 = new javax.swing.JLabel();
        campoAvalNeuro = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        areaAlterClin = new javax.swing.JTextArea();
        jLabel21 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        areaConclusao = new javax.swing.JTextArea();
        botaoSalvar = new javax.swing.JButton();
        botaoAnterior = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jLabel3.setText("Idade:");

        jLabel2.setText("Paciente:");

        jLabel1.setFont(new java.awt.Font("Andalus", 1, 14)); // NOI18N
        jLabel1.setText("Clínica Médica");

        jLabel4.setText("Enfermaria:");

        jLabel18.setText("Exame Físico Especial");

        jLabel5.setText("Segmento Cefálico:");

        jLabel6.setText("Tórax:");

        jLabel7.setText("Abdome:");

        comboAbdome.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Plano", "Globoso", "Escavado" }));

        jLabel8.setText("Doloroso:");

        comboDoloroso.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Sim", "Não" }));

        jLabel9.setText("Baço:");

        jLabel10.setText("Fígado:");

        jLabel11.setText("RHA:");

        jLabel12.setText("Edemas:");

        jLabel13.setText("Outros:");

        jLabel14.setText("Data da Última Menstruação:");

        campoUltMenstruacao.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter()));
        campoUltMenstruacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                campoUltMenstruacaoActionPerformed(evt);
            }
        });
        campoUltMenstruacao.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                campoUltMenstruacaoKeyPressed(evt);
            }
        });

        jLabel15.setText("Observações:");

        jLabel16.setText("Nível e Estado Neurológico:");

        jLabel17.setText("Observasões Específicas:");

        jLabel19.setText("Avaliação Neurológica:");

        jLabel20.setText("Alterações Clínicas a Ressaltar:");

        areaAlterClin.setColumns(20);
        areaAlterClin.setRows(5);
        jScrollPane1.setViewportView(areaAlterClin);

        jLabel21.setText("Conclusão:");

        areaConclusao.setColumns(20);
        areaConclusao.setRows(5);
        jScrollPane2.setViewportView(areaConclusao);

        botaoSalvar.setText("Salvar");
        botaoSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoSalvarActionPerformed(evt);
            }
        });

        botaoAnterior.setText("< Anterior");
        botaoAnterior.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoAnteriorActionPerformed(evt);
            }
        });

        jButton3.setText("Cancelar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING)
            .addComponent(jSeparator3)
            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoSegCefalico))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoTorax))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboAbdome, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel8)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(comboDoloroso, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel9)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoBaco, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel10)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoFigado))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoRHA))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoEdemas, javax.swing.GroupLayout.PREFERRED_SIZE, 390, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel13)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoOutros))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel17)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoObsEspec, javax.swing.GroupLayout.PREFERRED_SIZE, 309, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                        .addComponent(jLabel14)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoUltMenstruacao, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jLabel15)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoObservacoes, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel16)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoNeurologico))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jLabel19)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(campoAvalNeuro))))
                            .addComponent(jScrollPane1)
                            .addComponent(jScrollPane2)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel18)
                                    .addComponent(jLabel20)
                                    .addComponent(jLabel21))
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoNome, javax.swing.GroupLayout.PREFERRED_SIZE, 600, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoIdade, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jLabel4)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(campoEnferm, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE))))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 835, Short.MAX_VALUE)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(botaoAnterior)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jButton3)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(botaoSalvar)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel18)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(campoNome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3)
                    .addComponent(campoIdade, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(campoEnferm, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(campoSegCefalico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(campoTorax, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(comboAbdome, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(comboDoloroso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(campoBaco, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10)
                    .addComponent(campoFigado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(campoRHA, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(campoEdemas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13)
                    .addComponent(campoOutros, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14)
                    .addComponent(campoUltMenstruacao, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15)
                    .addComponent(campoObservacoes, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(campoNeurologico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel17)
                    .addComponent(campoObsEspec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19)
                    .addComponent(campoAvalNeuro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel20)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel21)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(botaoSalvar)
                    .addComponent(botaoAnterior)
                    .addComponent(jButton3))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoSalvarActionPerformed
        salvar();
    }//GEN-LAST:event_botaoSalvarActionPerformed

    private void botaoAnteriorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoAnteriorActionPerformed
        setVisible(false);
        TelaFichaCMExameFisicoGeral.getInstance().setVisible(true);
    }//GEN-LAST:event_botaoAnteriorActionPerformed

    private void campoUltMenstruacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_campoUltMenstruacaoActionPerformed

    }//GEN-LAST:event_campoUltMenstruacaoActionPerformed

    private void campoUltMenstruacaoKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_campoUltMenstruacaoKeyPressed
        if(evt.getKeyChar() != '\b'){
            campoUltMenstruacao.setText(Formatador.formataData(campoUltMenstruacao.getText()));
        }
    }//GEN-LAST:event_campoUltMenstruacaoKeyPressed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        TelaFichaCMExameFisicoEspecial.getInstance().limpaCampo();
        TelaFichaCMExameFisicoGeral.getInstance().limpaCampos();
        setVisible(false);
    }//GEN-LAST:event_formWindowClosing

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        TelaFichaCMExameFisicoEspecial.getInstance().limpaCampo();
        TelaFichaCMExameFisicoGeral.getInstance().limpaCampos();
        setVisible(false);
    }//GEN-LAST:event_jButton3ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(TelaFichaCMExameFisicoEspecial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(TelaFichaCMExameFisicoEspecial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(TelaFichaCMExameFisicoEspecial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(TelaFichaCMExameFisicoEspecial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                TelaFichaCMExameFisicoEspecial.getInstance().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextArea areaAlterClin;
    private javax.swing.JTextArea areaConclusao;
    private javax.swing.JButton botaoAnterior;
    private javax.swing.JButton botaoSalvar;
    private javax.swing.JTextField campoAvalNeuro;
    private javax.swing.JTextField campoBaco;
    private javax.swing.JTextField campoEdemas;
    private javax.swing.JTextField campoEnferm;
    private javax.swing.JTextField campoFigado;
    private javax.swing.JTextField campoIdade;
    private javax.swing.JTextField campoNeurologico;
    private javax.swing.JTextField campoNome;
    private javax.swing.JTextField campoObsEspec;
    private javax.swing.JTextField campoObservacoes;
    private javax.swing.JTextField campoOutros;
    private javax.swing.JTextField campoRHA;
    private javax.swing.JTextField campoSegCefalico;
    private javax.swing.JTextField campoTorax;
    private javax.swing.JFormattedTextField campoUltMenstruacao;
    private javax.swing.JComboBox comboAbdome;
    private javax.swing.JComboBox comboDoloroso;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JSeparator jSeparator3;
    // End of variables declaration//GEN-END:variables
    private static TelaFichaCMExameFisicoEspecial instance = null;
    private FichaClinicaMedica ficha;
    private boolean editable;
}
